Golang Module After 1.14
Published Date: 2020-08-05 13:02:19Z
I have get a lots of build errors from Golang compiler after update my local Golang program for version Golang 1.14.
Errors like:
- import cycle not allowed
- package worker is not in GOROOT
- can't find ...
And I have get a help from Discord.
You should declare the top level project as a module, then import `my/module/name/moduleName`.
You could try to solve it if your problem(s) also from Golang module(Golang version 1.14).
I provide steps for an example below.
- Create a folder name "app" for your application.
- Create a Golang file name "main.go" in "app".
- Create a folder name "myModule" in "app".
- Create a Golang file name "myModule.go" in "myModule".
- run "go mod app" in "app".(in terminal)
After these, you could import myModule
in main.go
with import "app/myModule"